<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="pages"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<%@ page isELIgnored="false"%>

<html>
<head>
  	<base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"  %>" />

	<title><s:text name="title" /> - <decorator:title default="Welcome!" /></title>
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <link rel="stylesheet" type="text/css" href="jquery/nyroModal/styles/nyroModal.full.css" />
	<script type="text/javascript" language="javascript" src="jquery/jquery-1.4.2.js" ></script>
	<script type="text/javascript" language="javascript" src="jquery/nyroModal/jquery.nyroModal-1.6.2.pack.js" ></script>
	<script type="text/javascript" language="javascript" src="jquery/strutsValidation/jquery.strutsValidation.js" ></script>
	<script type="text/javascript" language="javascript" src="js/console.non-debug.js" ></script>

	<decorator:head  />
	
	<script type="text/javascript" language="javascript">
		var state = new Object();
		var expiredObjects = new Object();
		var origOverflow;

		jQuery(window).resize(function() {
			jQuery("#container").css("min-height", function(){ return jQuery(document).height() });

			if(jQuery.browser.msie) {
				jQuery("#container").css("height", function(){ return jQuery(document).height()-5 });
			}
		});
			
		jQuery(document).ready(function() {
			origOverflow = jQuery("body").css("overflow");
			jQuery("#container").css("min-height", function(){ return jQuery(document).height() });

			if(jQuery.browser.msie) {
				jQuery("#container").css("height", function(){ return jQuery(document).height()-5 });
			}
		});

		/*
			Bind State
		*/
		jQuery(document).bind('documentInit', function() {
			jQuery(document).bind('expired', function(){
				/* 
				 * Refresh navbar on expired event
				 */
				var separator = " &raquo; ";
				var html = new String();
				if(state.navBar != null) {	
					jQuery.each(state.navBar, function (index, obj) {
						if(obj.link.length != 0) {	
							if(separator != null && html.length != 0) html += separator; 
							html += '<a href="' + obj.link + '">' + obj.label + '</a>';
						} else {
							if(separator != null && html.length != 0) html += separator; 
							html += '' + obj.label + '';
						}
					});
				}
				jQuery("#navBar").html(html);
	
				/* 
				 * Refresh content menu on expired event
				 */
	
				jQuery("#contentHeaderMenu").html("");
				if(state.menuItems != null) {
					html = new String();
					jQuery.each(state.menuItems, function (index, obj) {
						html += '<a href="' + obj.link + '" id="'+ obj.tagId +'" class="'+ obj.tagClass + '" title="'+obj.label+'"/>&nbsp;</a>';
					});
					jQuery("#contentHeaderMenu").html(html);
					jQuery("#contentHeaderMenu a.modal").nyroModal({
						endShowContent: function(elts, settings) {
							jQuery("body").css("overflow","hidden");
							if(jQuery.browser.msie) {
								elts.content.css({ // Reset the CSS at the start position
							      width: (elts.content.width() + 30) + "px"
							    });
							}
						},
						endRemove: function() {
							jQuery("body").css("overflow",origOverflow);
						}
					});
				}
			});
			jQuery(window).bind( 'hashchange', function(){
				jQuery(document).trigger("hashModified");
			});
		});

	</script>	
</head>

<c:set var="meta.content_menu" scope="request"><decorator:getProperty property="meta.content_menu"/></c:set>

<body>
	<div id="container">
		<div id="indentContainer">
			<div id="header">
				<div id="logo"><img src="images/logo.gif" /></div>
				<div id="headerMenuContainer">
					<div id="headerMenuLeft">&nbsp;</div>
					<div id="headerMenu">
						<div id="headerMenuContent">
							<sec:authorize ifAllGranted="ROLE_USER">  
								<a href="project/showProject" class="home" title="<s:text name="icon.home" />"><span>&nbsp;</span></a>
								<a href="projectSearch/search" class="search" title="<s:text name="icon.search" />"><span>&nbsp;</span></a>
							</sec:authorize>
						</div>
						<div id="headerMenuUser">
							<sec:authorize ifAllGranted="ROLE_USER">  
								<span id="username"><sec:authentication property="principal.username" /></span>
								<span id="logout"><a href="j_spring_security_logout" title="<s:text name="icon.logout" />"><span>&nbsp;</span></a></span>
							</sec:authorize>
						</div>
						<div class="globalWrap">&nbsp;</div>
					</div>
					<div id="headerMenuRight">&nbsp;</div>
					<div class="globalWrap">&nbsp;</div>
				</div>
				<div class="globalWrap">&nbsp;</div>
			</div>
			<div id="contentContainer">
				<div id="contentHeader">
					<div id="contentHeaderLeft">&nbsp;</div>
					
					<div id="contentHeaderContent">
						<div id="navBar">&nbsp;</div>
						<div id="contentHeaderMenu">&nbsp;</div>
					</div>
					<div id="contentHeaderRight">&nbsp;</div>
				</div>
				<div id="contentContainerContent">
					<decorator:body />
				</div>
				<div id="footer">
					cryProject v0.8b005
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript" language="javascript">
		jQuery(document).ready(function() {
			console.log("%s: %o", "Document ready in main_layout", this);

			jQuery(document).trigger("documentInit");

			//console.log("%s: %o", "Triggering 'hashModified'", this);
			//jQuery(document).trigger("hashModified");

			jQuery(document).trigger("documentReady");
		});
	</script>
	
</body>
</html>